﻿namespace WayneGameSolution.Packs
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Runtime.CompilerServices;

    public abstract class WorkingPack : Pack, IWorkingPack
    {
        protected IWorkingPackNode _RootValueNode;
        protected bool _Validated;

        public WorkingPack(int flag) : base(flag)
        {
            this._RootValueNode = new WorkingPackNode { Name = "root" };
            this._RootValueNode = new WorkingPackNode { Name = "Root" };
        }

        [DebuggerStepThrough, CompilerGenerated]
        private static IWorkingPackNode _Lambda__21(IWorkingPackNode tn)
        {
            return tn;
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            this._RootValueNode = null;
        }

        public IWorkingPackNode LocateNode(string[] routeArray)
        {
            IWorkingPackNode n = this.RootValueNode;
            foreach (string s in routeArray)
            {
                _Closure__2 VBClosure_ClosureVariable_21_C;
                VBClosure_ClosureVariable_21_C = new _Closure__2(VBClosure_ClosureVariable_21_C) {
                    VBLocal_tmps = s
                };
                IEnumerable<IWorkingPackNode> ns = n.ChildNodes.Where<IWorkingPackNode>(new Func<IWorkingPackNode, bool>(VBClosure_ClosureVariable_21_C._Lambda__20)).Select<IWorkingPackNode, IWorkingPackNode>(new Func<IWorkingPackNode, IWorkingPackNode>(WorkingPack._Lambda__21));
                if (ns.Count<IWorkingPackNode>() == 0)
                {
                    return null;
                }
                n = ns.ElementAtOrDefault<IWorkingPackNode>(0);
            }
            return n;
        }

        public IWorkingPackNode RootValueNode
        {
            get
            {
                return this._RootValueNode;
            }
            set
            {
                this._RootValueNode = value;
            }
        }

        public bool Validated
        {
            get
            {
                return this._Validated;
            }
        }

        public IWorkingPackNode WayneGameSolution.Packs.IWorkingPack.RootValueNode
        {
            get
            {
                return this._RootValueNode;
            }
            set
            {
                this._RootValueNode = value;
            }
        }

        public bool WayneGameSolution.Packs.IWorkingPack.Validated
        {
            get
            {
                return this._Validated;
            }
        }

        [CompilerGenerated]
        internal class _Closure__2
        {
            public string VBLocal_tmps;

            [DebuggerNonUserCode]
            public _Closure__2()
            {
            }

            [DebuggerNonUserCode]
            public _Closure__2(WorkingPack._Closure__2 other)
            {
                if (other != null)
                {
                    this.VBLocal_tmps = other.VBLocal_tmps;
                }
            }

            [DebuggerStepThrough, CompilerGenerated]
            public bool _Lambda__20(IWorkingPackNode tn)
            {
                return (tn.Name == this.VBLocal_tmps);
            }
        }
    }
}

